home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Programming / MuManual / Include / mmu / exceptions.i < prev    next >
Text File  |  2000-04-02  |  11KB  |  288 lines

  1.         IFND MMU_EXCEPTIONS_I
  2. MMU_EXCEPTIONS_I        SET     1
  3. ;*************************************************************************
  4. ;** mmu.library                                                         **
  5. ;**                                                                     **
  6. ;** a system library for arbitration and control of the MC68K MMUs      **
  7. ;**                                                                     **
  8. ;** © 1998 THOR-Software, Thomas Richter                                **
  9. ;** No commercial use, reassembly, modification without prior, written  **
  10. ;** permission of the authors.                                          **
  11. ;** Including this library in any commercial software REQUIRES a        **
  12. ;** written permission and the payment of a small fee.                  **
  13. ;**                                                                     **
  14. ;**---------------------------------------------------------------------**
  15. ;** exception related definitions                                       **
  16. ;**                                    **
  17. ;** $VER: 40.50 (31.10.99)                        **
  18. ;*************************************************************************
  19.  
  20.         IFND EXEC_TYPES_I
  21.         INCLUDE "exec/types.i"
  22.         ENDC ; EXEC_TYPES_I
  23.  
  24.         IFND EXEC_PORTS_I
  25.         INCLUDE "exec/ports.i"
  26.         ENDC ; EXEC_PORTS_I
  27.  
  28.         IFND EXEC_INTERRUPTS_I
  29.         INCLUDE "exec/interrupts.i"
  30.         ENDC ; EXEC_INTERRUPTS_I
  31.  
  32.  
  33. ;* The exception data structure. This structure is passed in register a0
  34. ;* for exception hooks and is the one and only information source about
  35. ;* the exception. This structure will be deleted as soon as the exception
  36. ;* terminates, hence make a copy for private use if you need to pass it
  37. ;* over to someone else.
  38.  
  39.     STRUCTURE ExceptionData,0
  40.         APTR            exd_Task                ;struct Task *
  41. ;* The task that caused the exception. Meaningless if this is the exception
  42. ;* handler of the (a) supervisor context. *
  43.  
  44.         APTR            exd_Context             ;struct MMUContext *
  45. ;* The context this exception is part of. *
  46.  
  47.         APTR            exd_Descriptor          ;ULONG *
  48. ;* The true physical hardware descriptor as seen by the MMU. In case of
  49. ;* an indirect descriptor, this points to the pointer, not to (your) page
  50. ;* descriptor itself. *
  51.  
  52.         APTR            exd_NextDescriptor      ;ULONG *
  53. ;* In case of a misaligned access, i.e. an access that passes a page
  54. ;* boundary, the descriptor of the second page involved in the access.
  55. ;* Otherwise identical to exd_Descriptor *
  56.  
  57.         APTR            exd_FaultAddress
  58. ;* The address that failed. *
  59.  
  60.         APTR            exd_NextFaultAddress
  61. ;* This is the final end address, inclusively, of a failed access.
  62. ;* Note that this might well be less than "exd_FaultAddress", e.g. if the
  63. ;* faulty instruction is a movem.l regs,-(ax).
  64. ;*
  65. ;* ABS(exd_FaultAdress-exd_NextFaultAddress)+1 is the size of the access
  66. ;* that failed. Usually 1, 2 and 4 for byte, word and longword accesses, but
  67. ;* other sizes are possible as well. In case you're writing a swapper daemon,
  68. ;* make sure you make all addresses within this range valid.
  69.  
  70.  
  71.         ULONG           exd_UserData
  72. ;* User data for the first page in the failed access if available. This is
  73. ;* the block Id for swapped out pages. *
  74.  
  75.         ULONG           exd_NextUserData
  76. ;* User data for the second page in a misaligned access. Identical to
  77. ;* exd_UserData otherwise. *
  78.  
  79.         ULONG           exd_Data
  80. ;* CPU output pipeline, right justified, if available, i.e. if the page(s)
  81. ;* is (are) marked as MAPP_REPAIRABLE.
  82. ;* Can be modified for your code, provided you set the EXDF_READBACK flag
  83. ;* and the page is repairable. In this case, this data will be loaded back
  84. ;* to the input pipeline of the CPU. *
  85.  
  86.         APTR            exd_ReturnPC
  87. ;* The approximate PC of the faulted instruction. Note that the real PC
  88. ;* might differ due to instruction prefetch. The program is guaranteed
  89. ;* to continue the "right" PC, however.
  90. ;* In case you set the EXDF_CALL flag, this is the pointer to a routine that
  91. ;* will be called by the library in user mode, e.g. for posting a message
  92. ;* to the swapper daemon. *
  93.  
  94.         ULONG           exd_Flags
  95. ;* A flags field, see below for the definitions. *
  96.  
  97.         ULONG           exd_Properties
  98. ;* Properties of the accessed memory *
  99.  
  100.         ULONG           exd_NextProperties
  101. ;*Properties of the next descriptor, if misaligned *
  102.  
  103.         UBYTE           exd_internal
  104. ;* Do not read or write this byte. *
  105.  
  106.         UBYTE           exd_FunctionCode
  107. ;* The function code mask of the access. *
  108.  
  109.         BYTE            exd_Level
  110. ;* The level of the *exd_Descriptor responsible for the fault. "0" is the
  111. ;* level A, "1" is level B and so on. Note that this is different from how
  112. ;* the 680x0 MMUs count. *
  113.  
  114.         BYTE            exd_NextLevel
  115. ;* The level of the *exd_NextDescriptor in case of a misalgined access.
  116. ;* Identical to exd_Level otherwise. *
  117.  
  118.         STRUCT          exd_DataRegs,8*4
  119. ;* A copy of the data registers of the faulty program. For higher magic,
  120. ;* you *might* be able to modify these. *
  121.  
  122.         STRUCT          exd_AddrRegs,7*4
  123. ;* A copy of the address registers, a0 to a6. a7 is below. *
  124.  
  125.         APTR            exd_SSP
  126. ;* The supervisor stack pointer, points to the exception stack frame.
  127. ;* DO NOT touch this stack frame, this is the buisiness of the library. *
  128.  
  129.         APTR            exd_USP
  130. ;* The user stack pointer. *
  131.  
  132.         APTR            exd_SysBase     ;struct SysBase *
  133. ;* A cached copy of the exec.library base address. DO NOT access AbsExecBase
  134. ;* within an exception handler, this will be fatal. Use either a private
  135. ;* copy or this field. *
  136.  
  137.         APTR            exd_MMUBase     ;struct MMUBase *
  138. ;* The base of the mmu.library. *
  139.  
  140.         LABEL           exd_SIZE
  141.  
  142. ;*************************************************************************
  143. ;* The flags set in exd_Flags, above. Note that there are more flags than
  144. ;* documented here, but DO NOT touch or interpret these.
  145.  
  146. ;* input flags    (set by the exception handler)        *
  147.  
  148.  
  149. EXDF_WRITE              equ     (1<<0)
  150. EXDB_WRITE              equ     0
  151. ;* A faulty write if set. A read exception if reset.
  152. ;* A 060 read/modify/write access will invoke the exception handler twice.
  153. ;* Note that locked transfers (what is called a RMW-access on a 020 or 030)
  154. ;* are neither handled by the Amiga hardware nor the mmu.library software. *
  155.  
  156. EXDF_INSTRUCTION        equ     (1<<1)
  157. EXDB_INSTRUCTION        equ     1
  158. ;* A faulty instruction access. This means specifically that you MAY NOT
  159. ;* provide read-back data. You've either to stop the task, or swap in a page.
  160. ;* Note that EXDF_WRITE and EXDF_INSTRUCTION are possible in case a faulty
  161. ;* program uses a "moves" instruction with the dfc register loaded with an
  162. ;* instruction function code. Note, too, that the os never tries to do that
  163. ;* and that this method is not supported by the mmu.library. *
  164.  
  165. EXDF_WRITEPROTECTED     equ     (1<<2)
  166. EXDB_WRITEPROTECTED     equ     2
  167. ;* The fault was due to a write to a write protected page. *
  168.  
  169. EXDF_WRITEDATAUNKNOWN   equ     (1<<3)
  170. EXDB_WRITEDATAUNKNOWN   equ     3
  171. ;* The mmu library could not get hold of the data actually written out,
  172. ;* exd_Data is invalid. Set pages to MAPP_REPAIRABLE to get write data. *
  173.  
  174. EXDF_SUPERVISOR         equ     (1<<6)
  175. EXDB_SUPERVISOR         equ     6
  176. ;* The fault was due to access of a supervisor only page. *
  177.  
  178. EXDF_MISALIGNED         equ     (1<<8)
  179. EXDB_MISALIGNED         equ     8
  180. ;* The access spawned more than one page in memory. *
  181.  
  182.  
  183. ;* The following flags are output flags. You may set them in your code and
  184. ;* they are respected by the library. *
  185.  
  186. EXDF_READBACK           equ     (1<<16)
  187. EXDB_READBACK           equ     16
  188. ;* Fill the input pipeline of the CPU with the data in exd_Data, right
  189. ;* justified. *
  190.  
  191. EXDF_WRITECOMPLETE      equ     (1<<16)         ;* yes, the same number *
  192. EXDB_WRITECOMPLETE      equ     16
  193. ;* The exception handler was able to perform the writeback of exd_Data,
  194. ;* the CPU should ignore the faulty write and continue execution.
  195. ;* If this bit is not set, the access is retried. *
  196.  
  197. EXDF_CALL               equ     (1<<17)
  198. EXDB_CALL               equ     17
  199. ;* Call a routine in user mode, the address is given in exd_ReturnPC.
  200. ;* The access is retried as soon as this routine returns.
  201. ;* The user routine executes in user mode in the context of the task that
  202. ;* faulted and has full access to the multitasking machine of exec.
  203. ;* (This requires really a lot of meta-magic....).
  204. ;* Do NOT set EXDF_WRITECOMPLETED/EXDF_READBACK and EXDF_CALL at once, only
  205. ;* one of the two bits should be set. *
  206.  
  207.  
  208. ;* The next lines define the exception types, passed in for example to
  209. ;* AddContextHook(). This type determinates to which exception hook list
  210. ;* your hook will be added. *
  211.  
  212. MMUEH_SEGFAULT          equ     0
  213. ;* a segmentation fault, i.e. access of invalid or supervisor protected
  214. ;* memory, or writes to write-protected memory. *
  215.  
  216. MMUEH_SWAPPED           equ     1
  217. ;* access of memory that is marked as "swapped out". *
  218.  
  219. MMUEH_SWITCH            equ     $10
  220. ;* called whenever a task looses the CPU. This is task specific and requires
  221. ;* that the specific task has been entered a context explicitly. This holds
  222. ;* even for the public default context. *
  223.  
  224. MMUEH_LAUNCH            equ     $11
  225. ;* called whenever a task gains control over the CPU. *
  226.  
  227. MMUEH_PAGEACCESS        equ     $20
  228. ;* called on installation of a MAPP_SINGLE page. *
  229.  
  230.  
  231. ;* The next structure is the exception handler itself. Note that this is
  232. ;* *NOT* the full definition. This structure is really "internal use only"
  233. ;* you should not read or write it. It's only documented here for complete-
  234. ;* ness. *
  235.  
  236.         STRUCTURE ExceptionHook,IS_SIZE
  237.         LABEL exh_SIZE
  238.  
  239. ;* The next structure is sent to the "Catcher" port for the high-level
  240. ;* message hook mechanism. *
  241.  
  242.         STRUCTURE ExceptionMessage,MN_SIZE
  243.         STRUCT exm_Exception,exd_SIZE
  244.         LABEL exm_SIZE
  245.  
  246. ;* If this is replied, then the access is retried and the faulty task is
  247. ;* continued. *
  248.  
  249.  
  250. ;* The PageAccessData structure
  251. ;* this is passed to a page access handler
  252. ;* in register a0, with your data in a1 and a4.
  253. ;* This is only called for MAPP_SINGLE pages, at the
  254. ;* page level.
  255. ;* The code is called in supervisor level, with all
  256. ;* interrupts disabled. *
  257.  
  258.         STRUCTURE PageAccessData,0
  259.         ULONG                    pgad_Level
  260. ;* level of the tree that is getting build *
  261.  
  262.         APTR                     pgad_Address
  263. ;* the logical address this is build for *
  264.  
  265.         APTR                     pgad_Destination
  266. ;* where the descriptor will go to *
  267.  
  268.         APTR                     pgad_Context
  269. ;* the context this is build for *
  270.  
  271.         APTR                     pgad_MMUBase
  272. ;* The base of the mmu.library. *
  273.  
  274.         ULONG                    pgad_Properties
  275. ;* The properties for this descriptor *
  276.  
  277.         ULONG                    pgad_UserData
  278. ;* User data for the descriptor.
  279. ;* This is the user data for invalid/swapped pages,
  280. ;* the destination address for remapped pages and
  281. ;* the descriptor address for indirect pages. *
  282.         LABEL                   pgad_SIZE
  283.  
  284.  
  285.         ENDC    ;       MMU_EXCEPTIONS_I
  286.  
  287.  
  288.